package com.cz.nongyetongv5.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONObject;

public class ChanPinJianCeRecord implements Serializable {



	//计划任务
	private Plan plan=null;
	public Plan getPlan() {
		return plan;
	}
	public void setPlan(Plan plan) {
		this.plan = plan;
	}

	private Huanjie huanjie=null;
	private String area;
	private int nature;
	public int getNature() {
		return nature;
	}
	public void setNature(int nature) {
		this.nature = nature;
	}
	/**
	 * 检查行业
	 */
	public String sqlJiaChaHangYes(){
		if(jianChaHangYes==null)return null;
		String sql="";
		for(int i=0;i<jianChaHangYes.size();i++){
			sql+=" category="+jianChaHangYes.get(i).getId()+" or ";

		}
		if(sql.equals(""))return null;
		else
			return " and ("+sql+" category=100 ) ";

	}

	public String sqlDuixiangleixing(){
		if(duixiangleixing==null)return null;
		String sql="";
		for(int i=0;i<duixiangleixing.size();i++){
			sql+=" kind="+duixiangleixing.get(i).getId()+" or ";

		}
		if(sql.equals(""))return null;
		else
			return " and ("+sql+" category=100 ) ";

	}
	public String sqlDuixiangleixing(String[] ks){
		if(ks==null||ks.length==0)return " and 1=1 ";
		String sql="";
		for(int i=0;i<ks.length;i++){
			sql+=" kind="+ks[i]+" or ";

		}
		if(sql.equals(""))return " and 1=1 ";
		else
			return " and ("+sql+" kind=100 ) ";

	}
	public String sqlJianChaHangYes(String[] ks){
		if(ks==null||ks.length==0)return " and 1=1 ";
		String sql="";
		for(int i=0;i<ks.length;i++){
			sql+=" category="+ks[i]+" or ";

		}
		if(sql.equals(""))return " and 1=1 ";
		else
			return " and ("+sql+" category=100 ) ";

	}
	private List<JianChaHangYe> jianChaHangYes = new ArrayList<JianChaHangYe>();
	private List<Duixiangleixing> duixiangleixing = new ArrayList<Duixiangleixing>();

	public List<Duixiangleixing> getDuixiangleixing() {
		if( duixiangleixing ==null)  duixiangleixing = new ArrayList<Duixiangleixing>();
		return duixiangleixing;
	}

	public String getDuixiangleixingStr() {
		if(duixiangleixing!=null&&
				duixiangleixing.size()>0)
		{
			String back="";
			for(Duixiangleixing item :duixiangleixing){
				back+=item.getId()+",";

			}
			return back.substring(0,back.length()-1);


		}else{
			return "";
		}
	}
	public String getJianChaHangYesStr() {


		if(jianChaHangYes!=null&&jianChaHangYes.size()>0)
		{
			String back="";
			for(JianChaHangYe item :jianChaHangYes){
				back+=item.getId()+",";
			}
			return back.substring(0,back.length()-1);


		}else{
			return "";
		}
	}
	public void setDuixiangleixing(List<Duixiangleixing> duixiangleixing) {
		this.duixiangleixing = duixiangleixing;
	}

	/**
	 * ID 记录的ID
	 */
	private String id;

	/**
	 * 所属区域
	 */
	private Town[] towns = new Town[4];

	/**
	 * 抽验机构
	 */
	private ChouYanJiGou chouYanJiGou = null;

	/**
	 * 抽验人员
	 */
	private List<JianChaRenYuan> chouYangRenYuans = new ArrayList<JianChaRenYuan>();

	/**
	 * 首检单位
	 */
	private BeiJianDanWei shouJianDanWei = null;

	/**
	 * 样品信息的集合
	 */
	private ArrayList<YangPin> yangPins = new ArrayList<YangPin>();

	/**
	 * 任务来源的集合
	 */
	private RenWuLaiYuan renWuLaiYuan = null;

	/**
	 * 检测类别
	 */
	private JianCeLeiBie jianCeLeiBie = null;

	/**
	 * 产品类别
	 */
	private ChanPinLeiBie chanPinLeiBie = null;

	/**
	 * 检测方法
	 */
	private JianCeFangFa jianCeFangFa = null;

	/**
	 * 检测依据
	 */
	private JianCeYiJu jianCeYiJu = null;

	/**
	 * 所有的照片信息
	 *
	 */
	private ArrayList<Photo> photos = new ArrayList<Photo>();

	/**
	 * 默认情况下为缓存状态
	 */
	private int state = 0;

	/**
	 * 数据生成的时间
	 */
	private String time;

	/**
	 * 签名的地址
	 */
	private String qianMingPath = null;

	/**
	 * 用户的名称
	 */
	private String username;

	private String fileId;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Town getKnowTown() {
		if (towns[3] != null) {
			return towns[3];
		}

		if (towns[2] != null) {

			return towns[2];
		}

		if (towns[1] != null) {

			return towns[1];
		}

		if (towns[0] != null) {

			return towns[0];
		}

		return null;

	}

	public Town[] getTowns() {
		return towns;
	}

	public void setTowns(Town[] towns) {
		this.towns = towns;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public List<JianChaRenYuan> getChouYangRenYuans() {
		return chouYangRenYuans;
	}

	public void setChouYangRenYuans(List<JianChaRenYuan> chouYangRenYuans) {
		this.chouYangRenYuans = chouYangRenYuans;
	}

	public BeiJianDanWei getShouJianDanWei() {
		return shouJianDanWei;
	}

	public void setShouJianDanWei(BeiJianDanWei shouJianDanWei) {
		this.shouJianDanWei = shouJianDanWei;
	}

	public ArrayList<YangPin> getYangPins() {
		return yangPins;
	}

	public void setYangPins(ArrayList<YangPin> yangPins) {
		this.yangPins = yangPins;
	}

	@Override
	public boolean equals(Object o) {

		if (o == null) {

			return false;
		}

		if (!(o instanceof ChanPinJianCeRecord)) {

			return false;
		}

		ChanPinJianCeRecord data = (ChanPinJianCeRecord) o;

		if (data.getId() == this.getId()) {

			return true;
		} else {

			return false;
		}
	}

	public ArrayList<Photo> getPhotos() {
		return photos;
	}

	/**
	 * 获得上传的photo
	 *
	 * @return
	 */
	public List<Photo> getUploadPhoto() {

		List<Photo> photos = new ArrayList<Photo>();

		if (this.photos != null) {

			for (Photo photo : this.photos) {

				if (photo.isUpload()) {

					photos.add(photo);

				}
			}
		}

		return photos;

	}

	public void setPhotos(ArrayList<Photo> photos) {
		this.photos = photos;
	}

	public String getQianMingPath() {
		return qianMingPath;
	}

	public void setQianMingPath(String qianMingPath) {
		this.qianMingPath = qianMingPath;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public RenWuLaiYuan getRenWuLaiYuan() {
		return renWuLaiYuan;
	}

	public void setRenWuLaiYuan(RenWuLaiYuan renWuLaiYuan) {
		this.renWuLaiYuan = renWuLaiYuan;
	}

	public JianCeLeiBie getJianCeLeiBie() {
		return jianCeLeiBie;
	}

	public void setJianCeLeiBie(JianCeLeiBie jianCeLeiBie) {
		this.jianCeLeiBie = jianCeLeiBie;
	}

	public ChanPinLeiBie getChanPinLeiBie() {
		return chanPinLeiBie;
	}

	public void setChanPinLeiBie(ChanPinLeiBie chanPinLeiBie) {
		this.chanPinLeiBie = chanPinLeiBie;
	}

	public JianCeFangFa getJianCeFangFa() {
		return jianCeFangFa;
	}

	public void setJianCeFangFa(JianCeFangFa jianCeFangFa) {
		this.jianCeFangFa = jianCeFangFa;
	}

	public JianCeYiJu getJianCeYiJu() {
		return jianCeYiJu;
	}

	public void setJianCeYiJu(JianCeYiJu jianCeYiJu) {
		this.jianCeYiJu = jianCeYiJu;
	}

	public ChouYanJiGou getChouYanJiGou() {
		return chouYanJiGou;
	}

	public void setChouYanJiGou(ChouYanJiGou chouYanJiGou) {
		this.chouYanJiGou = chouYanJiGou;
	}

	public String getFileId() {
		return fileId;
	}

	public void setFileId(String fileId) {
		this.fileId = fileId;
	}

	public List<JianChaHangYe> getJianChaHangYes() {
		return jianChaHangYes;
	}

	public void setJianChaHangYes(List<JianChaHangYe> jianChaHangYes) {
		this.jianChaHangYes = jianChaHangYes;
	}
	public Huanjie getHuanjie() {
		return huanjie;
	}
	public void setHuanjie(Huanjie huanjie) {
		this.huanjie = huanjie;
	}
	public String getArea() {

		return area;
	}
	public void setArea(String area) {
		this.area = area;
	}

}
